'''
Description: 
Author: Zilu
Date: 2021-11-04 12:33:34
Version: 
LastEditTime: 2021-11-04 12:46:29
LastEditors: Zilu
'''

# 定义函数
def my_abs(x):
    if not isinstance(x, (int, float)):
        raise TypeError('bad operand type')     # 抛出异常
    if x<0:
        return -x
    else:
        return x

if __name__ == '__main__':    
    print(my_abs(-99))

# 如果没有return语句，函数执行完毕后也会返回结果，只是结果为None。return None可以简写为return

